package com.coincalf.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.coincalf.entity.AccountDetail;
import com.coincalf.mapper.AccountDetailMapper;
import com.coincalf.service.AccountDetailService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


/**
 * <p>
 * 资金账户流水 服务实现类
 * </p>
 *
 * @author qiang
 * @since 2018-05-16
 */
@Service
public class AccountDetailServiceImpl extends ServiceImpl<AccountDetailMapper, AccountDetail> implements AccountDetailService {


    @Override
    public Page<AccountDetail> queryList(String businessType, Long userId, Long coinId, Page<AccountDetail> page) {
        EntityWrapper<AccountDetail> wrap = new EntityWrapper<>();
        wrap.eq("user_id", userId);
        if (!StringUtils.isEmpty(businessType)) {
            wrap.eq("business_type", businessType.trim());
        }
        if (coinId != null) {
            wrap.eq("coin_id", coinId);
        }
        wrap.orderBy("created", false);
        return super.selectPage(page, wrap);
    }

}
